<?php
class Default_Model_DbTable_Exclusion extends Zend_Db_Table_Abstract
{
	 protected $_name = 'hae_bdd_exclusions';
	 protected $_sequence=true;
     protected $_primary='id';
	public function getexclusions($id)
	{
	    $id = (int)$id;
	    $row = $this->fetchRow('id=' . $id);
		if(!$row)
		{ 
			throw  new Exception("Could not find row {$id}");
		}
		return $row->toArray();
	}
	public function getlistexclusion($exclusion)
	{
	    //Locale
	    $locale = new HAE_Element_Locale();
	    $lang = $locale->getLocale();
	    
		$list_exclusion = explode("_", $exclusion);
		$str = "";
		for ($i=0;$i<count($list_exclusion)-2;$i++ )
		{
			$str.= "id = ".$list_exclusion[$i]." OR ";
		}
		$str.="id = ".$list_exclusion[count($list_exclusion)-2];
	
		$select = $this->select();
		$select->from($this->_name,array('id','title_'.$lang.' AS title'));
		$select->where($str);
	
		return $this->fetchAll($select);
	}
}
?>